var App = (function(lng, undefined) {


    lng.App.init({
        name: 'Kitchen Sink',
        version: '1.2',
        resources: {
            sections: [
            'navigation.html',
            'aside.html'
            ]
        }
    });

    var _getEnvironmentFromQuoJS = (function() {
        var environment = lng.Core.environment();
        if (environment.isMobile) {
    // alert('Your phone is ' + environment.os.name + ' (' + environment.os.version + ')');
    }
    })();

    lng.View.Element.count('#btn-one', 7);
    lng.View.Element.count('#btn-three', 0);
    lng.View.Element.count('#aside-one', 17);

    return {

    };

})(LUNGO);

var map;
var geocoder;

function initialize() {
    var myOptions = {
        zoom: 13,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('welcome'),
        myOptions);
    geocoder = new google.maps.Geocoder();
    // Try HTML5 geolocation
    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
            var pos = new google.maps.LatLng(position.coords.latitude,
                position.coords.longitude);

           
            
            var marker = new google.maps.Marker({
                position: pos,
                map: map,
                title: 'Uluru (Ayers Rock)'
            });

            map.setCenter(pos);
        }, function() {
            handleNoGeolocation(true);
        });
    } else {
        // Browser doesn't support Geolocation
        handleNoGeolocation(false);
    }
}

function handleNoGeolocation(errorFlag) {
    if (errorFlag) {
        var content = 'Error: The Geolocation service failed.';
    } else {
        var content = 'Error: Your browser doesn\'t support geolocation.';
    }

    var options = {
        map: map,
        position: new google.maps.LatLng(60, 105),
        content: content
    };

    var infowindow = new google.maps.InfoWindow(options);
    map.setCenter(options.position);
}

google.maps.event.addDomListener(window, 'load', initialize);
      
      
//function openAddress( address) {
         
  function openAddress( ) {    
   
   var address = document.getElementById("address").value;
    geocoder.geocode( {
        'address': address
    }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
           // map.setCenter(results[0].geometry.location);
            
            
             var infowindow = new google.maps.InfoWindow({
                map: map,
                position: results[0].geometry.location,
                content: 'Kunde'
            });
        } else {
            alert("Geocode was not successful for the following reason: " + status);
        }
    });
}

